package cn.tedu.ioc.beans;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

/**
 * 工人
 */
@Component
public class Worker {
    private String name = "光头强";
    @Autowired
    //@Qualifier("saw") // Bean ID (Bean Name)
    private Tool tool; //null

//    @Autowired
//    public Worker(Saw saw){
//        this.saw = saw;
//        System.out.println("Worker.Worker");
//    }
//
//    //修改saw属性
//    @Autowired
//    public void setSaw(Saw saw) {
//        this.saw = saw;
//        System.out.println("Worker.setSaw");
//    }

    public Worker(){
        System.out.println("创建工人");
    }
    /** 工人的工作方法 */
    public void work(){
        System.out.println(name+"使用"+tool+"砍树");
    }
}
